import request from '@/utils/request'
// 获取所有菜单信息
function getMenuAll () {
  return request({
    method: 'GET',
    url: '/boss/menu/getAll'
  })
}

// 获取所有菜单并按层级展示
function getMenuNodeList () {
  return request({
    method: 'GET',
    url: '/boss/menu/getMenuNodeList'
  })
}

// 保存或新增菜单
function menuSaveOrUpdate (data) {
  return request({
    method: 'POST',
    url: '/boss/menu/saveOrUpdate',
    data
  })
}

// 删除菜单
function menuDelet (id) {
  return request({
    method: 'DELETE',
    url: `/boss/menu/${id}`
  })
}

// 获取编辑菜单页面信息
function menuEdit (id) {
  return request({
    method: 'GET',
    url: '/boss/menu/getEditMenuInfo',
    params: { id }
  })
}

// 获取角色拥有的菜单列表
function getRoleMenus (id) {
  return request({
    method: 'GET',
    url: '/boss/menu/getRoleMenus',
    params: id
  })
}

// 给角色分配菜单
function allocateRoleMenus (data) {
  return request({
    method: 'POST',
    url: '/boss/menu/allocateRoleMenus',
    data
  })
}
export {
  getMenuAll,
  getMenuNodeList,
  menuSaveOrUpdate,
  menuDelet,
  menuEdit,
  getRoleMenus,
  allocateRoleMenus
}
